#班级：2023
#姓名：邬昱初
#学号：20202321
import math
def opera(a,b,operator):
    if   operator == "-":
         return a - b
    elif operator == "*":
         return a * b
    elif operator == "/":
         return a / b
    elif operator == "%":
         return a % b
    elif operator == "**":
         return a ** b
    elif operator == "+":
         return a + b
    else:
         return print("运算符有误，请输入正确的运算符")

def opera1(c,operator1):
    if operator1 == "sin":
        return math.sin(c)
    if operator1 == "cos":
        return math.cos(c)
    if operator1 == "tan":
        return math.tan(c)
    if operator1 == "arcsin":
        return math.asin(c)
    if operator1 == "arccos":
        return math.acos(c)
    if operator1 == "arctan":
        return math.atan(c)
    else:
        return print("运算符有误，请输入正确的运算符")
def opera2(d):
    num = 1
    if d < 0:
        print('负数没有阶乘！')
    elif d == 0:
        print('0的阶乘为1！')
    else:
        for i in range(1, d + 1):
            num *= i
        return num
n = int(input("欢迎使用简单计算器，请选择你要进行的运算前的分类数字：\n1.+ - * / % **\n2.sin cos tan arcsin arccos arctan\n3.数的阶乘\n"))
flag = n
while flag == 1:
    operator = input("请选择你要进行的运算：\n")
    a = int(input("运算数一："))
    b = int(input("运算数二："))
    if   operator == "-":
         print(opera(a,b, operator))
         flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    elif operator == "+":
         print(opera(a, b, operator))
         flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    elif operator == "*":
         print(opera(a, b, operator))
         flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    elif operator == "/":
         print(opera(a, b, operator))
         flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    elif operator == "%":
         print(opera(a, b, operator))
         flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    elif operator == "**":
         print(opera(a, b, operator))
         flag = int(input("选择运算类型（ ）或退出（0）？\n"))
while flag == 2:
    operator1 = input("请选择你要进行的运算：\n")
    c = int(input("运算数："))
    if operator1 == "sin":
        print(opera1(c, operator1))
        flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    if operator1 == "cos":
        print(opera1(c, operator1))
        flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    if operator1 == "tan":
        print(opera1(c, operator1))
        flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    if operator1 == "arcsin":
        print(opera1(c, operator1))
        flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    if operator1 == "arccos":
        print(opera1(c, operator1))
        flag = int(input("选择运算类型（ ）或退出（0）？\n"))
    if operator1 == "arctan":
        print(opera1(c, operator1))
        flag = int(input("选择运算类型（ ）或退出（0）？\n"))
while flag == 3:
    i = int(input("运算数："))
    print(opera2(i))
    flag = int(input("选择运算类型（ ）或退出（0）？\n"))